<template>
	<view>
		<view class="listbox" @tap="seeinfobyid" :data-id="item.id" v-for="item in lists">
			
			<view class="list_img">
				<image :src="item.image" mode="aspectFill"></image>
			</view>
			
			<view class="list_right">
				
				<view class="list_right1 font1">{{item.name}}</view>
				<view class="list_right2 font1">
					
					阅读量:{{item.see}} 来源:{{item.from}}
					
				</view>
				<view class="list_right2">
					
					发布时间:{{item.datetime}}
					
				</view>
			</view>
			
		</view>
	
	
		<view class="nolist" v-if="lists.length<1">
			<image src="/static/image/nolist.png" mode=""></image>
		</view>
	</view>
</template>

<script>
	
	import {curl} from 'common/api.js';
	export default {
		data() {
			return {
				lists:[],
				page:1
			}
		},
		
		onLoad() {
			
			this.lists=[];
			this.page=1;
			
			this.getnews();
			wx.showShareMenu({
				withShareTicket:true,
				menus:["shareAppMessage","shareTimeline"]
			})
				
		},
		//加载更多
		onReachBottom(){
			this.getnews();
		},
		
		onShareAppMessage(res) {
			
		},
		
		methods: {
			onShareTimeline(options) {
				let that = this
				  let data = {
					title:'办桶沟', // 默认是小程序的名称
					path: '/pages/index/index', // 页面路径，默认是当前页面，必须是以‘/’开头的完整路径
					imageUrl: '', // 图片封面，本地文件路径、网络图片路，支持PNG及JPG，默认当前页面截图，显示图片长宽比是 5:4。
					success: res => {
						
					},
					fail: res => {
					
					},
					complete: res => {}
				  }
				  return data
				
			},
				
			//最新消息
			getnews(){
				var that=this;
				var page=this.page;
				var lists=this.lists;
				
				curl('index/getnewss', {page:page}).then((res) => {
					console.log('最新消息',res.data);
					var list=res.data;
					
					if (list.length>0) {
						list.forEach(function(item){
							lists.push(item)
						})
						
						that.lists=lists;
						that.page=page+1;
					}	
					
				});
			},
			
			
			seeinfobyid(ret){
				var id=ret.currentTarget.dataset.id;
				uni.navigateTo({
					url:"/pages/article/info?id="+id
				})
			}
		}
	}
</script>

<style>
	.list_right2{
		height:37rpx;line-height: 37rpx;
		font-size: 24rpx;color: #747474;
	}
	.list_right1{
		font-size: 28rpx;font-weight: 500;color: #33333;
	}
	.list_right{
		width: 560rpx;margin-left: 20rpx;
		height: 120rpx;
	}
	.list_img>image{
		width: 120rpx;height: 120rpx;border-radius: 10rpx;
	}
	.list_img{
		width: 120rpx;height: 120rpx;margin-left: 25rpx;
	}
	.listbox{
		width: 100%;height: 180rpx;
		border-bottom: 1px solid #ececec;
		display: flex;align-items: center;
	}
</style>
